package net.lastcoder.ifserver.node;

import net.lastcoder.ifserver.packet.Event;
import net.lastcoder.ifserver.packet.Message;
import net.lastcoder.ifserver.session.Session;
import net.lastcoder.ifserver.session.UlaID;

import org.json.JSONException;

import java.util.HashMap;

/**
 *
 */
public abstract class Node {

	protected final String username;
	protected String name;
	protected HashMap<String, Object> attributes;

	public Node(String username, String name) {
		this.username = username;
		this.name = name;
		attributes = new HashMap<>();
	}

	public abstract char getResource();
	public abstract void processEvent(Session from, Event event) throws Exception;
	public abstract void processMessage(Session from, Message message);

	public String getName() {
		return name;
	}

	public String getUsername() {
		return username;
	}


	public void setName(String name) {
		this.name = name;
	}


	public HashMap<String, Object> getAttributes() {
		return attributes;
	}

	public Object getAttribute(String key) {
		return attributes.get(key);
	}

	public void setAttribute(String key, Object obj) {
		attributes.put(key, obj);
	}
}
